package com.itheima.homework.test07;

/*
 请定义一个描述矩形（MyRectangle）的类，包含宽和高两个属性，
 提供获取矩形周长（perimeter）和面积（area）的方法。
 并编写测试类进行测试
 */
public class MyRectangle {
    private int width;
    private int high;

    public MyRectangle() {
    }

    public MyRectangle(int width, int high) {
        this.width = width;
        this.high = high;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHigh() {
        return high;
    }

    public void setHigh(int high) {
        this.high = high;
    }

    public int perimeter() {
        int p = 2 * (high + width);
        return p;
    }
    public int area() {
        int a = high * width;
        return a;
    }
}
class demo7{
    public static void main(String[] args) {
        MyRectangle m = new MyRectangle(8,9);
        int p = m.perimeter();
        int a = m.area();
        System.out.println("面积为:"+a);
        System.out.println("周长为"+p);
    }
}
